/*
	@author : "likaituan",
	@email : "61114579@qq.com",
	@version : "4.0",
	@date : "2010-09-05",
	@lastime : "2011-8-18"
*/


~function(F){
	//手风琴组件
	F.accordion = F.Class({
		init : function (box, ops){
			this.box = F(box).border("#222");
			ops = ops || {};
			this.idx = ops.index || 0;
			
			this.dt = this.box.tags("dt").bg("#ccc");
			var h = Math.floor(this.dt.item(0).height()/2-8);
			this.dt.each(function(idx,fdom){
				var u = F.data("img/icon/16_222.png");
				fdom.append("div").float().size(16,16).css("background", "url("+u+") no-repeat").px("marginTop",h).bgpos(idx>0?-32:-64,-16);	  
				idx>0 && fdom.css("border-top", "1px dashed #222");						
				fdom.click(F.proxy(this,this._switch,idx));						
			},this);
			
			this.dd = this.box.tags("dd");
			this.h = this.dd.item(this.idx).height();			
			this.dd.bg("#fff");
		},
		//切换
		_switch : function(idx){
			if(idx==this.idx) return;
			
			this.dt.item(this.idx).last().bgpos(-32,-16);
			this.dt.item(idx).last().bgpos(-64,-16);		
			this.dd.item(this.idx).anime({height:0, duration:500});
			this.dd.item(idx).anime({height:this.h, duration:500});
			this.idx = idx;
		}
	});
}($1stjs);